<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>游泳馆管理系统 - 登录</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <script src="/js/jquery.min.js"></script>
    <script src="js/plugins/toastr/toastr.min.js"></script>

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
    <script>
        $(document).ready(function (){
            $("#login").click(function (){
                const username = $("#username").val()
                const password = $("#password").val()

                $.ajax({
                    url:'/login.do',
                    type:'post',
                    data:{
                        username,
                        password
                    },
                    dataType:'json',//服务器返回数据的类型
                    success:function(data){//成功时执行该函数，data就是服务器返回的数据
                        if(data.code==0){
                            location.href="/mgr/index.html"
                        }else{
                            //登录失败
                            $("#msg").html(data.msg)//向id是msg的标签，显示文字


                            toastr.options = {
                                closeButton: $('#closeButton').prop('checked'),
                                debug: $('#debugInfo').prop('checked'),
                                progressBar: $('#progressBar').prop('checked'),
                                positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right',
                                onclick: null
                            };

                            toastr.error(data.msg)

                        }
                    },
                    error:function(xhr,textStatus){//错误时执行该函数
                        console.log('错误')
                        console.log(xhr)
                        console.log(textStatus)
                    }
                })
            })
        })

    </script>

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>

                <div class="form-group">
                    <input type="text" class="form-control" placeholder="用户名" id="username" required="">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" id="password" required="">
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" id="login">登 录</button>
                <div id="msg"></div>
                </p>

        </div>
    </div>

    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.7"></script>

    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <!--统计代码，可删除-->

</body>

</html>
